/********************************************************************************************
** Copyright � 2011 Nokia Corporation. All rights reserved.
** Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
** Java and all Java-based marks are trademarks or registered trademarks of
** Sun Microsystems, Inc. Other product and company names mentioned herein may be
** trademarks or trade names of their respective owners.
**
** Subject to the conditions below, you may, without charge:
**
** �  Use, copy, modify and/or merge copies of this software and
**    associated content and documentation files (the �Software�)
**
** �  Publish, distribute, sub-licence and/or sell new software
**    derived from or incorporating the Software.
**
** Some of the documentation, content and/or software maybe licensed under open source
** software or other licenses.  To the extent such documentation, content and/or
** software are included, licenses and/or other terms and conditions shall apply
** in addition and/or instead of this notice. The exact terms of the licenses, disclaimers,
** acknowledgements and notices are reproduced in the materials provided.
**
** This file, unmodified, shall be included with all copies or substantial portions
** of the Software that are distributed in source code form.
**
** The Software cannot constitute the primary value of any new software derived
** from or incorporating the Software.
**
** Any person dealing with the Software shall not misrepresent the source of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
** HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
********************************************************************************************/
import Qt 4.7

Rectangle {
    id: routeinfodlg
    width: 300
    height: 260
    border.color: "#363264"
    border.width: 1
    z: 50

    property int fontpixelsize: 12

    function setInfo(lat1,lon1,street1,city1,country1,lat2,lon2,street2,city2,country2,distance,traveltime,repeat,time,ownername,ownerhometown,ownerphone)
    {


        fromlatlontext.text = lat1 + ", " + lon1 + "<br>" +
                street1 + "<br>" + city1 + ", " + country1;

        tolatlontext.text = lat2 + ", " + lon2 + "<br>" +
                street2 + "<br>" + city2 + ", " + country2;

        distandtimetext.text = "Distance: " + distance + " km <br>" + "Travel time: " + traveltime + "<hr>" +
                "Repeat: <font color=blue>" + repeat + "</font>, Time: <font color=blue>" + time + "</font>"



        var ownertext = ""
        if (ownername != "NA" || ownerphone != "NA" || ownerhometown != "NA")
        {
            ownertext = "Owner: ";
            if (ownername != "NA")
            {
                ownertext += ownername + " "
            }
            if (ownerphone != "NA")
            {
                ownertext += ownerphone + " "
            }
            if (ownerhometown != "NA")
            {
                ownertext += ownerhometown
            }
        }
        miscinfotext.text = ownertext
        routeinfodlg.visible = true
    }


    Rectangle
    {
        id: titlerect
        color: "#5d8eac"
        border.color: "#363264"
        height: 29
        anchors.right: parent.right
        anchors.left: parent.left
        anchors.top: parent.top
        anchors.rightMargin: 0
        anchors.leftMargin: 0
        anchors.topMargin: 0

        Text {
            id: titleid
            text: "Route info"
            anchors.leftMargin: 10
            anchors.topMargin: 5
            anchors.fill: parent
            anchors.verticalCenter: titlerect.verticalCenter
            font.family: "Arial"
            font.pixelSize: fontpixelsize+2
        }


    }


    MouseArea {
        id: titlerectmousearea
        anchors.fill: parent

        drag.target: routeinfodlg
        drag.axis: Drag.XandYAxis
        drag.minimumX: 0
        drag.maximumX: 1000
        drag.minimumY: 0
        drag.maximumY: 1000
    }


    Rectangle {
        id: frominforect
        height: 50
        color: "#00000000"
        border.color: "#363264"
        anchors.right: parent.right
        anchors.rightMargin: 0
        anchors.left: parent.left
        anchors.leftMargin: 0
        anchors.top: titlerect.bottom


        Image {
            id: image1
            width: 32
            height: 32
            anchors.left: parent.left
            anchors.leftMargin: 0
            anchors.topMargin: 0
            anchors.top: parent.top
            source: "routeFromSmall.png"
        }

        Text {
            id: fromlatlontext
            height:  parent.height
            text: "text"
            anchors.right: parent.right
            anchors.rightMargin: 0
            anchors.left: image1.right
            anchors.leftMargin: 0
            anchors.top: parent.top
            anchors.topMargin: 5
            font.pixelSize: fontpixelsize-2
        }
    }

    Rectangle {
        id: toinforect
        height: 50
        color: "#00000000"
        border.color: "#363264"
        anchors.left: parent.left
        anchors.leftMargin: 0
        anchors.right: parent.right
        anchors.rightMargin: 0
        anchors.top: frominforect.bottom
        anchors.topMargin: 0

        Image {
            id: image2
            width: 32
            height: 32
            anchors.left: parent.left
            anchors.leftMargin: 0
            anchors.topMargin: 0
            anchors.top: parent.top
            source: "routeToSmall.png"
        }

        Text {
            id: tolatlontext
            height: parent.height
            text: "text"
            anchors.right: parent.right
            anchors.rightMargin: 0
            anchors.left: image2.right
            anchors.leftMargin: 0
            anchors.top: parent.top
            anchors.topMargin: 5
            font.pixelSize: fontpixelsize-2
        }
    }

    Rectangle {
        id: distandtimeinforect
        height: 70
        color: "#00000000"
        border.color: "#363264"
        anchors.left: parent.left
        anchors.leftMargin: 0
        anchors.right: parent.right
        anchors.rightMargin: 0
        anchors.top: toinforect.bottom
        anchors.topMargin: 0

        Text {
            id: distandtimetext
            text: "text"
            anchors.leftMargin: 32
            anchors.topMargin: 5
            anchors.fill: parent
            font.pixelSize: fontpixelsize-2
        }
    }

    Rectangle {
        id: miscinforect
        height: 50
        color: "#00000000"
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 0
        border.color: "#363264"
        anchors.right: parent.right
        anchors.rightMargin: 0
        anchors.left: parent.left
        anchors.leftMargin: 0
        anchors.top: distandtimeinforect.bottom
        anchors.topMargin: 0

        Text {
            id: miscinfotext
            text: "text"
            anchors.leftMargin: 5
            anchors.topMargin: 5
            anchors.fill: parent
            font.pixelSize: fontpixelsize-2
        }


    }

    PushButton
    {
        id: closeid
        label: "Close"
        width: 80
        height: 26
        anchors.right: parent.right
        anchors.rightMargin: 10
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 10

        onButtonpressed:
        {
            routeinfodlg.visible = false
        }

    }

    PropertyAnimation {
        id: routeinfodlganimation
        target: routeinfodlg
        property: "scale"
        from: 0
        to: 1
        duration: 600
        easing.type: Easing.OutBounce
    }

    onVisibleChanged:
    {
        if (visible)
        {
            routeinfodlganimation.start()
        }
    }
}
